package com.qingke.Qiximybatis.business;

import java.util.List;
import org.apache.ibatis.session.SqlSession;

import com.qingke.Qiximybatis.QixiConsole;
import com.qingke.Qiximybatis.QixiDao;
import com.qingke.Qiximybatis.command.UserCommand;
import com.qingke.Qiximybatis.mapper.MyUserMapper;
import com.qingke.Qiximybatis.sqlclass.MyUser;

public class SelectMan11 extends UserCommand {
	public SelectMan11(MyUser user) {
		super(user);
	}
	
	@Override
	public void executeUserCommand() {
		SqlSession session = QixiDao.mybatisSession();
		System.out.println("请输入需要查找男性的特征：");
		int agexia = Integer.parseInt(QixiConsole.askUserInput("请你输入年龄的下限：>"));
		int ageshang = Integer.parseInt(QixiConsole.askUserInput("请你输入年龄的上限：>"));
		int heightxia = Integer.parseInt(QixiConsole.askUserInput("请你输入身高的下限：>"));
		int heightshang = Integer.parseInt(QixiConsole.askUserInput("请你输入身高的上限：>"));
		int age=0;
		int h=0;
		MyUserMapper userM = session.getMapper(MyUserMapper.class);
		List<MyUser> users = userM.genderAllUser("M");
		for (MyUser user : users) {
			age = Integer.parseInt(user.getAge());
			h = Integer.parseInt(user.getHeight());
			if((age>=agexia&&age<=ageshang)&&(h>=heightxia&&h<=heightshang)){
				System.out.println(user);
			}else{
				continue;
			}
		}
		session.close();
		System.out.println("查询结束！");
	}


}
